import os
import xlrd
import xlsxwriter

path='C:/Users/24200/Desktop/fsdownload/data'

caoyaodata=xlrd.open_workbook('caoyaodata.xlsx')
image_data=xlrd.open_workbook('image_data.xlsx')


new_image_data=xlsxwriter.Workbook('test.xlsx')
new_image_worksheet = new_image_data.add_worksheet(u'sheet1')#在文件中创建一个名为sheet1的sheet"

datasheet=caoyaodata.sheet_by_index(0)
imagesheet=image_data.sheet_by_index(0)
all_data_row=datasheet.nrows
all_image_row=imagesheet.nrows


dbtype_list = os.listdir(path)
for dbtype in dbtype_list[::]:
    if os.path.isfile(os.path.join(path,dbtype)):
        dbtype_list.remove(dbtype)
count = 0
for i in range(len(dbtype_list)):
    for j in range(1,all_image_row):
        image_row=imagesheet.row(j)
        if dbtype_list[i][:2]==image_row[3].value[6:8]:   
            count = count + 1          
            new_image_worksheet.write(count, 1,image_row[1].value)
            new_image_worksheet.write(count, 2, dbtype_list[i])
            new_image_worksheet.write(count, 3,image_row[3].value)
new_image_data.close() # 保存文件








